package cn.iocoder.yudao.module.xhyy.dal.mysql.hearing;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.xhyy.controller.app.hearing.vo.AppHearingPageReqVO;
import cn.iocoder.yudao.module.xhyy.dal.dataobject.hearing.HearingDO;
import cn.iocoder.yudao.module.xhyy.dal.dataobject.knowledge.KnowledgeDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.xhyy.controller.admin.hearing.vo.*;

/**
 * 听力资源 Mapper
 *
 * @author duanxinli
 */
@Mapper
public interface HearingMapper extends BaseMapperX<HearingDO> {

    default PageResult<HearingDO> selectPage(HearingPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<HearingDO>()
                .eqIfPresent(HearingDO::getId, reqVO.getId())
                .likeIfPresent(HearingDO::getHearingName, reqVO.getHearingName())
                .eqIfPresent(HearingDO::getChapter, reqVO.getChapter())
                .eqIfPresent(HearingDO::getBookId, reqVO.getBookId())
                .eqIfPresent(HearingDO::getGrade, reqVO.getGrade())
                .likeIfPresent(HearingDO::getBookName, reqVO.getBookName())
                .betweenIfPresent(HearingDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(HearingDO::getGrade)
                .orderByAsc(HearingDO::getChapter));
    }
    default PageResult<HearingDO> selectPage(AppHearingPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<HearingDO>()
                .eqIfPresent(HearingDO::getId, reqVO.getId())
                .likeIfPresent(HearingDO::getHearingName, reqVO.getHearingName())
                .eqIfPresent(HearingDO::getChapter, reqVO.getChapter())
                .eqIfPresent(HearingDO::getBookId, reqVO.getBookId())
                .eqIfPresent(HearingDO::getGrade, reqVO.getGrade())
                .likeIfPresent(HearingDO::getBookName, reqVO.getBookName())
                .betweenIfPresent(HearingDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(HearingDO::getId));
    }
}